const gulp = require('gulp')
const GulpSSH = require('gulp-ssh')

const gulpConfig = require('./gulp.config.js')

var gulpTestSSH = new GulpSSH({
  ignoreErrors: false,
  sshConfig: gulpConfig.ssh
})

gulp.task('clean', function() {
  return gulpTestSSH.shell(`rm -rf ${gulpConfig.remotePath}`)
})

gulp.task(
  'upload',
  gulp.series('clean', function() {
    return gulp.src(['./dist/**']).pipe(gulpTestSSH.dest(gulpConfig.remotePath))
  })
)

gulp.task('upload-system-static', function () {
  return gulp.src(['./src/system-static/**']).pipe(gulpTestSSH.dest(gulpConfig.systemStaticPath))
})

gulp.task(
  'default',
  gulp.series('upload', done => {
    console.log('upload done!')
    done()
  })
)
